package net.oschina.archx.spring.web;

import com.alibaba.fastjson.JSON;
import net.oschina.archx.spring.entity.EntityA;
import net.oschina.archx.spring.entity.EntityB;
import net.oschina.archx.spring.entity.EntityC;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * JsonTestController
 *
 * @author Archx
 * @date 2015/6/23 0023
 */
@Controller
@RequestMapping("/json")
public class JsonTestController {

    @RequestMapping("/list")
    @ResponseBody
    public List<Object> list() {
        List<Object> list = new ArrayList<Object>();
        EntityA a = new EntityA("admin");
        EntityB b = new EntityB(a);
        EntityC c = new EntityC(a);
        list.add(a);
        list.add(b);
        list.add(c);
        // 测试FASTJSON 循环应用为问题
        System.out.println(JSON.toJSONString(list));
        return list;
    }

}
